package club.kingyin.kyblogprofile.entity;

public enum FileType {
    PIC,VIDEO,MUSIC,FOLDER,DOCUMENT,DATA,WORD,EXCL,PPT,PDF,CODE,SQL,ZIP;

    public static FileType getType(String name) {
        if (!name.contains("."))
            return FileType.FOLDER;
        String[] split = name.split("\\.");
        String suffix = split[split.length - 1].toUpperCase();
        switch (suffix) {
            case "":
                return FileType.FOLDER;
            case "BMP":
            case "JPG":
            case "PNG":
            case "TIF":
            case "GIF":
            case "PCX":
            case "TGA":
            case "EXIF":
            case "FPX":
            case "SVG":
            case "PSD":
            case "CDR":
            case "PCD":
            case "DXF":
            case "UFO":
            case "EPS":
            case "AI":
            case "RAW":
            case "WMF":
            case "WEBP":
            case "AVIF":
            case "APNG":
            case "JPEG":
            case "ICO":
            case "HDRI":
            case "FLIC":
                return FileType.PIC;
            case "WMV":
            case "ASF":
            case "ASX":
            case "RM":
            case "RMVB":
            case "MP4":
            case "3GP":
            case "MOV":
            case "M4V":
            case "AVI":
            case "DAT":
            case "MKV":
            case "FLV":
            case "VOB":
                return FileType.VIDEO;
            case "WAV":
            case "FLAC":
            case "APR":
            case "ALAC":
            case "WAVPACK":
            case "WV":
            case "MP3":
            case "AAC":
            case "OGG":
            case "OGGVOBIS":
            case "OPUS":
                return FileType.MUSIC;
            case "DOC":
            case "DOCX":
            case "DOCM":
            case "DOTX":
            case "DOTM":
                return FileType.WORD;
            case "XLS":
            case "XLSX":
            case "XLSM":
            case "XLTX":
            case "XLTM":
            case "XLSB":
            case "XLAM":
                return FileType.EXCL;
            case "PPT":
            case "PPTX":
            case "PPTM":
            case "PPSX":
            case "POTX":
            case "POTM":
            case "PPAM":
                return FileType.PPT;
            case "PDF":
                return FileType.PDF;
            case "TXT":
                return FileType.DOCUMENT;
            case "MDB":
            case "DBF":
            case "ORA":
            case "CTL":
            case "LOG":
            case "ARC":
            case "MDF":
            case "LDF":
            case "MYD":
            case "MYL":
            case "FRM":
            case "DB":
            case "WDB":
            case "INX":
            case "LB":
            case "DMS":
            case "SQL":
                return FileType.SQL;
            case "H":
            case "C":
            case "HPP":
            case "HXX":
            case "CPP":
            case "CC":
            case "CXX":
            case "C++":
            case "A":
            case "I":
            case "II":
            case "M":
            case "O":
            case "S":
            case "CS":
            case "DLL":
            case "JAVA":
            case "CLASS":
            case "PHP":
            case "PM":
            case "PL":
            case "PY":
            case "PY3":
            case "PYC":
            case "PYO":
            case "PYD":
            case "PYI":
            case "PYX":
            case "PYZ":
            case "PYWZ":
            case "RPY":
            case "PYDE":
            case "PYP":
            case "PYT":
            case "KT":
            case "HTML":
            case "CSS":
            case "JS":
            case "VUE":
                return FileType.CODE;
            case "RAR":
            case "ZIP":
            case "ARJ":
            case "Z":
                return FileType.ZIP;
            default:return FileType.DATA;
        }
    }
}
